package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import vo.Student;
import dao.CourseDao;
import dao.ScoreDao;
import dao.StudentDao;
import dao.TeacherDao;
//@WebServlet("Stu_modifyServlet")
public class Stu_modifyServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String stuno = (String)( ((Student)req.getSession().getAttribute("student")).getStuno());
		String stuname = (String)req.getParameter("stu_name");
		String stupwd = (String)( ((Student)req.getSession().getAttribute("student")).getPassword());		
		String stusex=(String)req.getParameter("stu_sex");	
		String stutel = (String)req.getParameter("stu_tel");
		String stuemail=(String)req.getParameter("stu_email");
		String stuclass=(String)req.getParameter("stu_class");
		String studept=(String)req.getParameter("stu_dept");
		StudentDao studao=new StudentDao();
		Student student;
		
		
		try {
			student = studao.getStudentByStuno(stuno);
			student.setPassword(stupwd);
			student.setStuclass(stuclass);
			student.setStudept(studept);
			student.setStuemail(stuemail);
			student.setStuname(stuname);
			student.setStuno(stuno);
			student.setStusex(stusex);
			student.setStutel(stutel);
			studao.updateStudent(student);
			req.getSession().removeAttribute("student");
			req.getSession().setAttribute("student", student);
			req.getRequestDispatcher("/jsp/student/stu_form.jsp?flag=1").forward(req, resp);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
